<?php
class Admin_Form_Product_ValidateImage{
	
public static function validate($arrParam = null, $options = null){
	
		$upload 		= new Zend_File_Transfer_Adapter_Http();
		$config 		= new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'product-category.ini'));
		$arrConfig 		= $config->getConfig('item');
		
		$fileInfo 		= $upload->getFileInfo('image');
		$fileName 		= $fileInfo['image']['name'];
		
		if(!empty($fileName)){
			$upload->addValidator('Extension',true,$arrConfig['extension'],'image')
			 	   ->addValidator('Size',true,$arrConfig['size'],'image')
				   ->addValidator('ImageSize',true,$arrConfig['imageSize'],'image');
			
			if(!$upload->isValid('image')){
				$message = $upload->getMessages();
				$error = current($message);							
			}
		}
		return $error;	
	}
}